﻿using Microsoft.Extensions.DependencyInjection;
using SQLitePCL;
using StockUI.ViewModels;
using System.Configuration;
using System.Data;
using System.Runtime.InteropServices;
using System.Windows;

namespace StockUI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            Services = ConfigureServices();
           
        }

        /// <summary>
        /// Gets the current <see cref="App"/> instance in use
        /// </summary>
        public new static App Current => (App)Application.Current;

        /// <summary>
        /// Gets the <see cref="IServiceProvider"/> instance to resolve application services.
        /// </summary>
        public IServiceProvider Services { get; }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            new MainWindow().Show();
        }

        /// <summary>
        /// Configures the services for the application.
        /// </summary>
        private static IServiceProvider ConfigureServices()
        {
            var services = new ServiceCollection();

            // View models
            services.AddSingleton<MainViewModel>();
            services.AddSingleton<GpsjViewModel>();
            services.AddSingleton<HomeViewModel>();
            services.AddSingleton<ZtgcViewModel>();
            services.AddSingleton<CgfxViewModel>();
            services.AddSingleton<LssjViewModel>();
            services.AddSingleton<NoteTaskViewModel>();

            return services.BuildServiceProvider();
        }
    }
}
